package personal.wang.message;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @className: Message
 * @Description:
 * Message 的格式设计
 * 32bit    |32bit          |32bit   |8bit | 不定长度
 * version  |session length |session |flag | data
 * version => 1
 * session length => 36
 * session       => UUID
 * flag          => 消息类型, 0b0000 0001 -> 请求数据，data 为 long ，offset 的值
 *                          0b0000 0010 -> 提交 offset ， data 为 long ，offset 的值
 *                          0b0000 0011 -> 提交心跳 ， data 为 IP +　state
 *                          0b1000 0001 -> 发送数据，data 为数据，byte[]
 * @Author: wangyifei
 * @Date: 2024/6/4 11:08
 */
public class Message {
    private static Logger logger = LoggerFactory.getLogger(Message.class);
    private Header header ;
    private byte[] content ;
    public Message(Header header , byte[] content){
        this.header = header ;
        this.content = content ;
    }

    public Header getHeader() {
        return header;
    }

    public void setHeader(Header header) {
        this.header = header;
    }

    public byte[] getContent() {
        return content;
    }

    public void setContent(byte[] content) {
        this.content = content;
    }

    @Override
    public String toString() {
        return "Message{" +
                "header=" + header +
                ", content='" + content + '\'' +
                '}';
    }
}
